package rehab.host.gui;

import rehab.host.gui.ListTransferHandler;
import java.awt.*;
import javax.swing.*;

public class SensorDrop extends TransferHandler{

    public JList listSensor;
    public JList listEmpty;
    ListTransferHandler arrayListHandler = new ListTransferHandler();
    
    public JPanel getContent() {
        JPanel panel = new JPanel(new GridLayout(5,0));
        panel.add(getSensorListComponent());
        panel.add(getEmptyListComponent());
        return panel;
    }

    private JScrollPane getEmptyListComponent() {
        DefaultListModel model = new DefaultListModel();

        listEmpty = new JList(model);
        listEmpty.setName("Configure List");
        listEmpty.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        listEmpty.setTransferHandler(arrayListHandler);
        listEmpty.setDragEnabled(true);
        return new JScrollPane(listEmpty);

    }

    private JScrollPane getSensorListComponent() {
        DefaultListModel model = new DefaultListModel();

        model.addElement("ACCELEROMETER SENSOR X");
        model.addElement("ACCELEROMETER SENSOR Y");
        model.addElement("ACCELEROMETER SENSOR Z");
        model.addElement("ACCELEROMETER SENSOR TILT X");
        model.addElement("ACCELEROMETER SENSOR TILT Y");
        model.addElement("ACCELEROMETER SENSOR TILT Z");
        model.addElement("TEMPRATURE SENSOR");
        model.addElement("LIGHT SENSOR");
        model.addElement("SENSOR PORT A0");
        model.addElement("SENSOR PORT A1");
        model.addElement("SENSOR PORT A2");
        model.addElement("SENSOR PORT A3");
        

        listSensor = new JList(model);
        listSensor.setName("Sensor List");
        listSensor.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        listSensor.setTransferHandler(arrayListHandler);
        listSensor.setDragEnabled(true);
//        listSensor.
        return new JScrollPane(listSensor);
    }

    public static void createAndShowGUI() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        f.getContentPane().add(new SensorDrop().getContent());
        f.setSize(400,200);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }
}